package com.lmf.controller;

import com.lmf.entity.User;
import com.lmf.service.UserService;
import com.lmf.tool.HttpUtil;
import com.lmf.tool.TokenDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/register")
    public User postUser(@RequestParam("username")String username, @RequestParam("password")String password){
        return userService.insertUser(username, password);
    }

    @PostMapping ("/login")
    public TokenDTO login(@RequestParam ("username")String username, @RequestParam ("password")String password){
        return userService.login(username, password);
    }
    /**
     * 测试
     */
    @GetMapping("/test")
    public void test(@RequestParam(value = "mobile")String mobile,@RequestParam(value = "content")String content) throws IOException {
        HttpUtil.postRequest();

    }

}
